#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;

const int INF = 1e18;

int main() {
    int N, M;
    while (cin >> N >> M) {
        if ( N == 0 ) break;
        vector<vector<tuple<int, int, int>>> adj(N);
        for (int i = 0; i < M; ++i) {
            int x, y, p, t;
            cin >> x >> y >> p >> t;
            adj[x].push_back({y, p, t});
        }
        int required_visits = N - 1;
        if ( required_visits == 0 ) {
            cout << 0 << endl;
            continue;
        }
        int max_mask = 1 << N;
        vector<vector<vector<int>>> dp(max_mask, vector<vector<int>>(N, vector<int>(7, INF)));
        dp[0][0][0] = 0;
        vector<vector<int>> groups(N + 1);
        for (int mask = 0; mask < max_mask; ++mask) {
            int cnt = __builtin_popcount(mask);
            groups[cnt].push_back(mask);
        }
        int min_cost = INF;
        bool can_complete = false;
        for (int k = 0; k <= required_visits; ++k) {
            for (int mask: groups[k]) {
                if ( k == required_visits ) {
                    for (int u = 0; u < N; ++u) {
                        for (int t_mod = 0; t_mod < 7; ++t_mod) {
                            if ( dp[mask][u][t_mod] == INF ) continue;
                            for (auto &edge: adj[u]) {
                                int v, p, t_move;
                                tie(v, p, t_move) = edge;
                                if ( v != 0 ) continue;
                                int total_time_mod = (t_mod + t_move) % 7;
                                if ( total_time_mod == 5 || total_time_mod == 6 ) {
                                    int candidate = dp[mask][u][t_mod] + p;
                                    if ( candidate < min_cost ) {
                                        min_cost = candidate;
                                    }
                                }
                                can_complete = true;
                            }
                        }
                    }
                } else {
                    for (int u = 0; u < N; ++u) {
                        for (int t_mod = 0; t_mod < 7; ++t_mod) {
                            if ( dp[mask][u][t_mod] == INF ) continue;
                            for (int v = 0; v < N; ++v) {
                                if ( mask & (1 << v)) continue;
                                for (auto &edge: adj[u]) {
                                    int dest, p, t_move;
                                    tie(dest, p, t_move) = edge;
                                    if ( dest != v ) continue;
                                    int new_mask = mask | (1 << v);
                                    int new_t_mod = (t_mod + t_move + 1) % 7;
                                    int new_cost = dp[mask][u][t_mod] + p;
                                    if ( new_cost < dp[new_mask][v][new_t_mod] ) {
                                        dp[new_mask][v][new_t_mod] = new_cost;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if ( min_cost != INF ) {
            cout << min_cost << endl;
        } else {
            if ( can_complete ) {
                cout << "Oh, My god!" << endl;
            } else {
                cout << "It's not my thing!" << endl;
            }
        }
    }
    return 0;
}